<?php

$list = "";

$list .= "               <div id='dialog' title='List dialog'>\n";
$list .= "                    <br />     \n";
if($_REQUEST['Tabela'] == 'Nova')
{
     $list .= "                         <table cellpadding='0' cellspacing='0' border='0' class='display' id='TABLE'>\n";
}
else if($_REQUEST['Tabela'] == 'Jqgrid')
{
     $list .= "                    <div align='center'>\n";
     $list .= "                    <table id='list_dialog'></table>\n";
     $list .= "                    <div id='pager_list_dialog'></div>\n";
     $list .= "                    </div>\n";
}
else
{
     $list .= "                    <div align='left'>\n";
     $list .= "                         <br />\n";
     $list .= "                         <span id='toolbar_list' class='ui-widget-header ui-corner-all'>\n";
     $list .= "                              <button id='beginning'>Inicio</button>\n";
     $list .= "                              <button id='rewind'>Anterior</button>\n";
     $list .= "                              <button id='forward'>Próximo</button>\n";
     $list .= "                              <button id='end'>Último</button>\n";
     $list .= "                         </span>\n";
     $list .= "                    </div>\n";
     $list .= "                    <br />    \n";
     $list .= "                    <div align='center'>\n";
     $list .= "                         <table border='1' width='100%' id='LISTA'>\n";
}
if($_REQUEST['Tabela'] != 'Jqgrid')
{
     $list .= "                              <thead>\n";
     $sql = sprintf("SELECT label,tipo FROM Page_mount WHERE Tabela='%s' AND lista > '0' ORDER BY lista", $TABLE);
     $result = mysql_query($sql, $dbctl);
     if($result == 0)
     {
          printf("<h1>Falha: %s</h1>\n", mysql_error($dbctl));
          printf("<h3>%s</h3>\n", $sql);
          exit;
     }
     else
     {
          if(mysql_num_rows($result) > 0)
          {
               $list .= "                                   <tr>";
               $cols = 0;
               $th = "";
               while($myrow = mysql_fetch_row($result))
               {
                    if($myrow[1] == "mediumblob")
                    {
                         continue;
                    }
                    $th .= "<th>$myrow[0]</th>";
                    $cols++;
               }
               $list .= $th . "</tr>\n";
          }
     }
     $list .= "                              </thead>\n";
     $list .= "                              <tbody>\n";
     if($_REQUEST['Tabela'] == 'Nova')
     {
          $list .= "                                   <tr>\n";
          $list .= "                                        <td colspan='" . $cols . "' class='dataTables_empty'>Carregando Dados do Servidor</td>\n";
          $list .= "                                   </tr>\n";
     }
     else
     {
          for($l = 0; $l < 15; $l++)
          {
               $list .= "                                   <tr>\n";
               for($r = 0; $r < $cols; $r++)
               {
                    $list .= sprintf("                                        <td id='L%dC%d'>&nbsp;</td>\n", $l + 1, $r + 1);
               }
               $list .= "                                   </tr>\n";
          }
     }
     $list .= "                              </tbody>\n";
     $list .= "                              <tfoot><tr>".$th."</tr></tfoot>\n";
     $list .= "                         </table>\n";
     if($_REQUEST['Tabela'] == 'Antiga')
     {
          $list .= "                    </div>\n";
     }
}
$list .= "               </div>\n";
$out .= $list;
?>
